package pub.guoxin.oops.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.querydsl.core.annotations.QueryEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import pub.guoxin.oops.tidy.LocalDateTimeDeserializer;
import pub.guoxin.oops.tidy.LocalDateTimeSerializer;

import java.time.LocalDateTime;

/**
 * Created by guoxin on 17-10-18.
 */
@Data
@Entity
@QueryEntity
@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
public class RealTimeDeviceDataInfo {

    @Id
    private String id;

    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime dateTime;

    private String remark;

    private String realTimeCommunicationId;
    /**
     * 压缩系数比
     */
    private Float compressibilityRatio;
    /**
     * 修正系数比
     */
    private Float correctionCoefficient;
    /**
     * K系数
     */
    private Float kCoefficient;
    /**
     * 仪表K系数
     */
    private Float meterKCoefficient;
    /**
     * 温度测量错误时代替值
     */
    private Float errorTemperature;
    /**
     * 气压测量错误时代替值
     */
    private Float errorAirPressure;
    /**
     * 标况累积量
     */
    private Double normCumulant;
    /**
     * 工况累积量
     */
    private Long workCumulant;
    /**
     * 错误标况累积量
     */
    private Double errorNormCumulant;
    /**
     * 错误工况累积量
     */
    private Long errorWorkCumulant;
    /**
     * 工况压力
     */
    private Float workPressure;
    /**
     * 工况温度
     */
    private Float workTemperature;
    /**
     * 工况瞬时流量
     */
    private Float workMomentFlow;
    /**
     * 标况瞬时流量
     */
    private Float normMomentFlow;
    /**
     * 电池电量
     */
    private Float batteryLevel;

    public RealTimeDeviceDataInfo(DeviceDataInfo deviceDataInfo, String realTimeCommunicationId) {
        this.dateTime = deviceDataInfo.getDateTime();
        this.id = deviceDataInfo.getSn();
        this.batteryLevel = deviceDataInfo.getBatteryLevel();
        this.compressibilityRatio = deviceDataInfo.getCompressibilityRatio();
        this.correctionCoefficient = deviceDataInfo.getCorrectionCoefficient();
        this.errorAirPressure = deviceDataInfo.getErrorAirPressure();
        this.errorNormCumulant = deviceDataInfo.getNormCumulant();
        this.errorTemperature = deviceDataInfo.getErrorTemperature();
        this.errorWorkCumulant = deviceDataInfo.getErrorWorkCumulant();
        this.meterKCoefficient = deviceDataInfo.getMeterKCoefficient();
        this.normCumulant = deviceDataInfo.getNormCumulant();
        this.normMomentFlow = deviceDataInfo.getNormMomentFlow();
        this.realTimeCommunicationId = realTimeCommunicationId;
        this.workCumulant = deviceDataInfo.getWorkCumulant();
        this.workMomentFlow = deviceDataInfo.getWorkMomentFlow();
        this.workPressure = deviceDataInfo.getWorkPressure();
        this.workTemperature = deviceDataInfo.getWorkTemperature();
    }

}
